package fun.ticsmyc.designPattern;

/**
 * 懒单例
 * @author Ticsmyc
 * @date 2020-03-25 21:48
 */
public class Singleton2 {

    private volatile static Singleton2 instance;

    private Singleton2(){}

    public static Singleton2 getInstance(){
        if(instance == null){
            synchronized (Singleton2.class){
                if(instance == null){
                    instance = new Singleton2();
                }
            }
        }
        return instance;
    }
}
